import Vue from 'vue'
import Vuex from 'vuex'
import * as actions from './actions'
import * as getters from './getters'

Vue.use(Vuex)

// 应用初始状态
const state = {
    selectIds: [], // 题目分类级联选择的id数组
    subTitle: "添加题目", // 新增/编辑题目面包屑
    topicId: null, //题目id
    watchJson:{}, // 查看题目信息
}

// 定义所需的 mutations
const mutations = {
    saveSelectIds(state, params) {
        state.selectIds = params.selectIds;
    },
    saveTopicId(state, params) {
        state.topicId = params.topicId;
    },
    saveTitle(state, params) {
        state.subTitle = params.subTitle;
    },
    saveWatch(state, params) {
        state.watchJson = params.watchJson;
    },
}

// 创建 store 实例
export default new Vuex.Store({
    actions,
    getters,
    state,
    mutations
})